var express = require('express');
var router = express.Router();
var pjson = require("../package.json");
const {successData} = require("../utils/response");
const {exec} = require('child_process');

/* GET home page. */
router.get('/', function (req, res, next) {
  // console.log("=====", process.env.NODE_ENV )
  let showFlag = req.query.showFlag
  let showView = process.env.NODE_ENV == 'development' || showFlag
  res.render('index', {
    title: 'Express',
    apiObj: showView ? {path: "/api.html", title: '接口文档'} : {},
    deployObj: showView ? {path: "/deploy.html", title: '项目部署'} : {},
    frontObj: showView ? {path: "/chat/index.html#/", title: "客户端前端项目"} : {},
    systemObj: showView ? {path: "/system/index.html#/login", title: "后台管理系统项目"} : {},
  });
});

router.get("/deployProject", function (req, res) {
  console.log("deployProject===")
  let command="ls -l"
  // let command = "git clone"
  exec(command, (error, stdout, stderr) => {
    return successData(res, {stdout, error, stderr})
  });
})


module.exports = router;
